#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

float minimym (float massiv[], int razmer)
{
	float result = massiv[0];
	int i;
	for( i = 0; i < razmer; i++ )
	if( massiv[i] < result )
	result = massiv[i];

	return result;
}
float maximym (float massiv[], int razmer)
{
	float result = massiv[0];
	int i;
	for( i = 0; i < razmer; i++ )
	if( massiv[i] > result )
	result = massiv[i];

	return result;
}
float srednee (float massiv[], int razmer)
{
	float result; 
	float sum = 0;
	int i;
	for (i = 0; i < razmer; i++)
		sum = sum + massiv[i];
	result = sum / razmer;
	return result;
}
float srednekvadr_otklonenie (float massiv[], int razmer)
{
	float result, s=0;
	int i;
	for (i=0; i<razmer; i++)
		s=s+(massiv[i]-srednee (massiv, razmer) )*(massiv[i]-srednee (massiv, razmer) );
	result = sqrt(s/(float)razmer);
	return result;
}
int max_chislo_idyshih_podryad (float massiv[], int razmer)
{
	int result=1, current=1;
	int i, k;
	int chislo[1000];
	
	for (i=0;i<1000;i++)
		chislo[i]=0;

	for (k=0;k<razmer;k++)
	{
		if (massiv[k]==massiv[k+1])
		current++;
		else 
		{	
			if (result<current)
				result=current;
			current=1;
		}
	}
		
	return result;
}
int max_dlina_monot_ychastka (float massiv[], int razmer)
{
	int result=1;
	int i, k;
	int chislo[1000];
	
	for (i=0;i<1000;i++)
		chislo[i]=0;

	for (k=0;k<razmer;k++)
	{
		if (massiv[k]>=massiv[k+1])
		result++;
		else 
		{	
			chislo[k]=result;
			result=1;
		}
	}
	
	result=chislo[0];
	for (i=1;i<razmer;i++)
	if (chislo[i]>result)
		result = chislo[i];
		
	return result;
}
float mediana (float massiv[], int razmer)
{
	float result, m =0;
	int i, l;
	for (i=0; i<razmer; i++)
	{
		for (l=0; l<(razmer-i-1); l++) 
		{
			if (massiv[l] > massiv[l+1])
			{  m = massiv[l]; massiv[l] = massiv[l+1] ; massiv[l+1] = m; }
		}	
	} 

	if (razmer % 2 == 0)
	{
		i = (razmer / 2);
		result = (massiv[i]+massiv[i+1])/2;
	}
	else
	{
		i = (razmer+1) / 2;
		result = massiv[i-1];
	}
	return result;
}

void main ()
{
	int i, s, razmer = 0;
	float massiv[1000];
	//float massiv[10000];
	
	/*memset(massiv, 0, sizeof(int) * N);

	
	r = 1
	for( i = 0; r != 0; i++ )
		r = scanf("%f", massiv + i);*/

	printf ("Vvedite chisla 4erez probel:  \n");

	for (i=0; i < 1000; i++){
		s=scanf ("%f", &massiv[i]);
		if (s == 0)
			break;
		razmer++;
	}

	printf("\nminimym: %f \n", minimym (massiv, razmer));
	printf("maximym: %f \n", maximym (massiv, razmer));
	printf("srednee: %f \n", srednee (massiv, razmer));
	printf("sredne_kvadraticheskoe_otklonenie: %f \n", srednekvadr_otklonenie (massiv,razmer));
	printf("max_chislo_idyshih_podryad: %d \n", max_chislo_idyshih_podryad (massiv,razmer));
	printf("max_dlina_monot_ychastka: %d \n", max_dlina_monot_ychastka (massiv, razmer));
	printf("mediana: %d \n", mediana (massiv, razmer));

	system("pause");
}